﻿package view.prompt
{
    import __AS3__.vec.*;
    import com.core.*;
    import com.greensock.*;
    import com.sh.game.global.*;
    import flash.display.*;
    import flash.utils.*;
    import morn.core.handlers.*;

    public class PromptGame extends Sprite
    {
        private var btnArr:Array;
        private var btnDic:Dictionary;
        public static const TYPE_TEAM:int = 1;

        public function PromptGame()
        {
            this.btnArr = [{name:"email", index:0, cls:EmailPrompt}, {name:"business", index:1, cls:BusinessPrompt}, {name:"union", index:2, cls:UnionChatPrompt}, {name:"private", index:3, cls:PrivateChatPrompt}, {name:"team", index:4, cls:TeamPrompt}, {name:"drug", index:5, cls:DrugPrompt}, {name:"money", index:6, cls:MoneyPropmpt}];
            this.btnDic = new Dictionary();
            return;
        }// end function

        private function addButton(param1:String, param2:Object = null) : void
        {
            var _loc_3:* = this.btnDic[param1];
            if (_loc_3 == null)
            {
                App.mloader3.loadSWF(Config.getUrl("assets/images/activeButton/" + param1 + ".swf"), 1, new Handler(this.swfComplete, [this.getBtnMsg(param1), param2]), null, null, false);
            }
            else
            {
                _loc_3.show(param2);
            }
            return;
        }// end function

        private function swfComplete(param1:Object, param2:Object, param3) : void
        {
            var _loc_4:* = this.btnDic[param1.name];
            if (this.btnDic[param1.name] == null)
            {
                _loc_4 = new (param1.cls as Class)();
                _loc_4.createCell(this, param1, new Handler(this.checkShowPos));
                this.btnDic[param1.name] = _loc_4;
            }
            _loc_4.show(param2);
            return;
        }// end function

        private function getBtnMsg(param1:String) : Object
        {
            var _loc_2:Object = null;
            for each (_loc_2 in this.btnArr)
            {
                
                if (param1 == _loc_2.name)
                {
                    return _loc_2;
                }
            }
            return null;
        }// end function

        private function checkShowPos() : void
        {
            var _loc_2:Object = null;
            var _loc_3:int = 0;
            var _loc_1:Array = [];
            for each (_loc_2 in this.btnDic)
            {
                
                if (_loc_2.visible == true)
                {
                    _loc_1[_loc_2._btnMsg.index] = _loc_2;
                }
            }
            _loc_3 = 0;
            for each (_loc_2 in _loc_1)
            {
                
                TweenLite.to(_loc_2, 1, {x:_loc_3 * 55 + 5});
                _loc_3++;
            }
            return;
        }// end function

        public function addChatTips(param1:int, param2:Object) : void
        {
            var _loc_3:Object = null;
            var _loc_4:Array = null;
            var _loc_5:Array = null;
            var _loc_6:Boolean = false;
            var _loc_7:Vector.<Object> = null;
            if (param1 == 3)
            {
                return;
            }
            switch(param1)
            {
                case 0:
                {
                    this.addButton("private", param2);
                    break;
                }
                case 1:
                {
                    this.addButton("union", param2);
                    break;
                }
                case 2:
                {
                    break;
                }
                default:
                {
                    break;
                }
            }
            return;
        }// end function

        public function closeEmail() : void
        {
            var _loc_1:* = this.btnDic["email"];
            if (_loc_1)
            {
                _loc_1.hide();
            }
            return;
        }// end function

        public function jiaoyiRequest() : void
        {
            this.addButton("business");
            return;
        }// end function

        public function emailRequest(param1:Boolean) : void
        {
            this.addButton("email", param1);
            return;
        }// end function

        public function removeChatTips(param1:int) : void
        {
            var _loc_2:IPrompt = null;
            switch(param1)
            {
                case 0:
                {
                    _loc_2 = this.btnDic["private"];
                    _loc_2.hide();
                    break;
                }
                case 1:
                {
                    _loc_2 = this.btnDic["union"];
                    _loc_2.hide();
                    break;
                }
                case 2:
                {
                    break;
                }
                default:
                {
                    break;
                }
            }
            return;
        }// end function

        public function setVPos(param1:int) : void
        {
            var _loc_2:* = ModelProxy.getValue("data", "chatScale");
            if (_loc_2)
            {
                TweenLite.to(this, 0.5, {y:GlobalLayer.instance.root.stage.stageHeight - 244 - 30 * param1 - 140});
            }
            else
            {
                TweenLite.to(this, 0.5, {y:GlobalLayer.instance.root.stage.stageHeight - 244 - 30 * param1});
            }
            return;
        }// end function

        public function setYaoShuiCount() : void
        {
            this.addButton("drug");
            return;
        }// end function

        public function update(param1:int, param2:Object) : void
        {
            switch(param1)
            {
                case TYPE_TEAM:
                {
                    this.addButton("team", param2);
                    break;
                }
                default:
                {
                    break;
                }
            }
            return;
        }// end function

        public function checkYuanBao() : void
        {
            var _loc_2:IPrompt = null;
            var _loc_3:Boolean = false;
            var _loc_1:* = ModelProxy.getValue("data", "yuanbao");
            if (_loc_1 > 0)
            {
                _loc_3 = ModelProxy.getValue("data", "tiQuYuanBaoIsOpen");
                if (_loc_3)
                {
                    _loc_2 = this.btnDic["money"];
                    if (_loc_2)
                    {
                        _loc_2.hide();
                    }
                }
                else
                {
                    this.addButton("money");
                }
            }
            else
            {
                _loc_2 = this.btnDic["money"];
                if (_loc_2)
                {
                    _loc_2.hide();
                }
            }
            return;
        }// end function

    }
}
